<html><head><meta charset="gb2312"/><title>Keyboard.pb</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<pre><font face="Courier New, Courier, mono"size="2"><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font><font color="#3A3966">;   PureBasic - Keyboard example file
</font><font color="#3A3966">;
</font><font color="#3A3966">;    (c) 2001 - Fantaisie Software
</font><font color="#3A3966">;
</font><font color="#3A3966">; ------------------------------------------------------------
</font><font color="#3A3966">;
</font>
<b><font color="#3A3966">If</font></b> <font color="#3A3966">InitKeyboard</font>() = 0 <b><font color="#3A3966">Or</font></b> <font color="#3A3966">InitSprite</font>() = 0
<font color="#3A3966">  MessageRequester</font>("Error", "Can't initialize the sprite system.", 0)
  <b><font color="#3A3966">End</font></b>
<b><font color="#3A3966">EndIf</font></b>

<font color="#3A3966">MessageRequester</font>("Information", "This will test the fast keyboard access..."+<font color="#FF0000">#LF$</font>+"Press 'ESC' to quit!", 0)


<b><font color="#3A3966">If</font></b> <font color="#3A3966">OpenScreen</font>(640, 480, 16, "Keyboard")

  x = 100
  y = 100
  
<font color="#3A3966">  LoadSprite</font>(0, "Data/PureBasic.bmp", 0)

  <b><font color="#3A3966">Repeat</font></b>
  
<font color="#3A3966">    FlipBuffers</font>()
    
<font color="#3A3966">    ClearScreen</font>(<font color="#3A3966">RGB</font>(0,0,0))
  
<font color="#3A3966">    ExamineKeyboard</font>()
    
    <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Left</font>)
      x-1
    <b><font color="#3A3966">EndIf</font></b>
  
    <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Right</font>)
      x+1
    <b><font color="#3A3966">EndIf</font></b>
  
    <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Up</font>)
      y-1
    <b><font color="#3A3966">EndIf</font></b>
  
    <b><font color="#3A3966">If</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Down</font>)
      y+1
    <b><font color="#3A3966">EndIf</font></b>
    
    <b><font color="#3A3966">For</font></b> OffsetY=0 <b><font color="#3A3966">To</font></b> 480 <b><font color="#3A3966">Step</font></b> 70
      <b><font color="#3A3966">For</font></b> OffsetX=0 <b><font color="#3A3966">To</font></b> 640 <b><font color="#3A3966">Step</font></b> 200
<font color="#3A3966">        DisplaySprite</font>(0, OffsetX+x, y+OffsetY)
      <b><font color="#3A3966">Next</font></b>
      
      <b><font color="#3A3966">For</font></b> OffsetX=0 <b><font color="#3A3966">To</font></b> 640 <b><font color="#3A3966">Step</font></b> 200
<font color="#3A3966">        DisplaySprite</font>(0, OffsetX+x+90, y+OffsetY+35)
      <b><font color="#3A3966">Next</font></b>
    <b><font color="#3A3966">Next</font></b>
    
  <b><font color="#3A3966">Until</font></b> <font color="#3A3966">KeyboardPushed</font>(<font color="#FF0000">#PB_Key_Escape</font>)

<b><font color="#3A3966">Else</font></b>
<font color="#3A3966">  MessageRequester</font>("Error", "Impossible to open a 680*480 16 bit screen",0)
<b><font color="#3A3966">EndIf</font></b>

<b><font color="#3A3966">End</font></b>    </font></pre>
</body></html>
